﻿--[[
	Widget name	  	ShadowFrame
	Author     	 	Kurapica
--]]
     
-- Script
do
	IGAS:NewAddon("IGAS_Studio")
	
	local _WidgetName = "ShadowFrame"
    local _Base = "Frame"

    -- Scripts
	local function OnSizeChanged(self)
		if self.__Frame:GetObjectType().Property.Width then
			self.__Frame.Height = self.Height
			self.__Frame.Width = self.Width
		end
	end
	
	-- ScriptType
	local _ScriptType = {
	}
	    
	-- Function
	local _Function = {
		-- SetName(name) - Set the name of the object.
        ["SetName"] = function(self, name)
            self:CallMethod(_Base, "SetName", name)
			if self.__Frame then
				self.__Frame.Name = name
			end
        end,
    }
    
	-- Property
	local _Property = {
		["TrueFrame"] = {
			["Set"] = function(self, frame)
				
			end,
			
			["Get"] = function(self)
				return self.__Frame
			end,
			
			["Type"] = IGAS:GetPropertyType("Object"),
		},
    }
    
    -- New    
    local function _New(name, parent, frameType, ...)
		local shadowF = CreateFrame(_Base, name, parent)

		if frameType then
			shadowF.__Frame = CreateFrame(frameType, nil, shadowF, ...)
			if shadowF.__Frame["SetAllPoints"] then
				shadowF.__Frame:SetAllPoints(shadowF)
			end
		end
		
		shadowF:StackScript("OnSizeChanged", OnSizeChanged)
		
		return shadowF
    end
	
	-- __index
	local function __index(self, k)
		return self.__Frame[k]
	end
	
	-- __newindex
	local function __newindex(self, k, v)
		self.__Frame[k] = v
	end
	
    local _WidgetInfo = {
        ["WidgetName"] = _WidgetName,
        ["Base"] = _Base,
        ["Function"] = _Function,
        ["Property"] = _Property,
        ["ScriptType"] = _ScriptType,
        ["New"] = _New,
		-- Special Item
		["__index"] = __index,
		["__newindex"] = __newindex,
    }
    
    Widget[_WidgetName] = IGAS:NewWidget(_WidgetInfo)
end